<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const nums = [1, 2, ["a", "b", [3, 4], 5, 6], 7, 8];
      function mapArr(arr) {
        arr.forEach((el) => {
          //1
          if (Array.isArray(el) === false) {
            console.log(el);
          } else {
            // 2
            el.forEach((el2) => {
              if (Array.isArray(el2) === false) {
                console.log(el2);
              } else {
                //3
                el2.forEach((el3) => {
                  if (Array.isArray(el3) === false) {
                    console.log(el3);
                  } else {
                  }
                });
              }
            });
          }
        });
      }
      mapArr(nums);
    </script>
  </body>
</html>
